package com.sunlands.zlcx.usercenter.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.sunlands.zlcx.usercenter.domain.ParentTargetDO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Objects;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ApiModel("考试目标父类")
public class ParentTargetVO implements Serializable {

    private static final long serialVersionUID = 725628697043431662L;
    private Long id;
    /**
     * 目标名称
     */
    @ApiModelProperty(position = 10, value = "目标名称")
    private String targetName;

    /**
     * 状态
     */
    private Integer status;

    /**
     * 创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date createTime;

    /**
     * 修改时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date updateTime;

    /**
     * 目标类型,考试还是其它
     * {@link ParentTargetDO.TargetEnums}
     */
    @ApiModelProperty(position = 20, value = "目标类型,考试还是其它")
    private Integer targetType;

    private Integer orders;

    private List<TargetVO> targetVOList;

    public static ParentTargetVO from(ParentTargetDO parentTargetDO) {
        return Objects.isNull(parentTargetDO)? null : ParentTargetVO.builder().id(parentTargetDO.getId())
                .targetName(parentTargetDO.getTargetName())
                .status(parentTargetDO.getStatus())
                .targetType(parentTargetDO.getTargetType())
                .createTime(parentTargetDO.getCreateTime())
                .updateTime(parentTargetDO.getUpdateTime())
                .build();
    }

}
